package com.recharge.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.entity.Customer;
import com.entity.Recharge;
import com.file.entity.FileCustomer;
import com.recharge.srevice.CloseAccountService;
import com.utils.JsonResult;

/**
 * @Title: CloseAccountController.java
 * @Package com.recharge.controller
 * @author 孙梦楠
 * @date 2017年8月29日 上午9:18:17
 * @version V1.0.0
 */
@RestController
@RequestMapping(value = "/recharge")
public class CloseAccountController {

	@Autowired
	private CloseAccountService closecccountservice;

	// 列出所有可销户,待销户，已销户的用户
	@RequestMapping(value = "/list_can_closeaccount_customer_total", method = RequestMethod.POST)
	public JsonResult<List<FileCustomer>> listallcustomer_total(@RequestBody Customer customer,
			@CookieValue(value = "opeorgcookie", required = false) String opeorgcookie,
			@CookieValue(value = "opetypecookie", required = false) String opetypecookie,
			@CookieValue(value = "languagecookie", required = false) String languagecookie) {

		String customeraccount = customer.getCustomeraccount();
		String customername = customer.getCustomername();
		String customeraddress = customer.getCustomeraddress();
		String customerrechargestatus  =customer.getCustomerrechargestatus();

		return closecccountservice.listallcustomer(opeorgcookie, opetypecookie, customerrechargestatus,customeraccount, customername,
				customeraddress,languagecookie,"总");

	}
	
	@RequestMapping(value = "/list_can_closeaccount_customer_child", method = RequestMethod.POST)
	public JsonResult<List<FileCustomer>> listallcustomer_child(@RequestBody Customer customer,
			@CookieValue(value = "opeorgcookie", required = false) String opeorgcookie,
			@CookieValue(value = "opetypecookie", required = false) String opetypecookie,
			@CookieValue(value = "languagecookie", required = false) String languagecookie) {

		String customeraccount = customer.getCustomeraccount();
		String customername = customer.getCustomername();
		String customeraddress = customer.getCustomeraddress();
		String customerrechargestatus  =customer.getCustomerrechargestatus();

		return closecccountservice.listallcustomer(opeorgcookie, opetypecookie, customerrechargestatus,customeraccount, customername,
				customeraddress,languagecookie,"分");

	}

	// 销户
	@RequestMapping(value = "/close_account", method = RequestMethod.POST)
	public JsonResult<Recharge> closeaccount(@RequestBody FileCustomer filecustomer,
			@CookieValue(value = "opecodecookie", required = false) String opecodecookie,
			@CookieValue(value = "opetypecookie", required = false) String opetypecookie) {

		Integer customerid = filecustomer.getCustomerid();

		return closecccountservice.close_account(customerid, opecodecookie,opetypecookie);
	}

//	// 销户列表
//	@RequestMapping(value = "/list_close_account", method = RequestMethod.POST)
//	public JsonResult<List<Recharge>> listclosing(@RequestBody Recharge recharge,
//			@CookieValue(value = "opeorgcookie", required = false) String opeorgcookie,
//			@CookieValue(value = "opetypecookie", required = false) String opetypecookie) {
//
//		String customeraccount = recharge.getCustomeraccount();
//		String customername = recharge.getCustomername();
//		String customeraddress = recharge.getCustomeraddress();
//
//		return closecccountservice.listclosing(customeraccount, customername, customeraddress, opetypecookie,
//				Integer.valueOf(opeorgcookie));
//	}

}
